package com.green.business.controller;


//import com.green.business.service.PALStatementService;
import com.green.business.service.PALStatementService;
import com.green.business.service.ReportsService;
import com.green.business.vo.InportVo;
import com.green.business.vo.ReportsVo;
import com.green.business.vo.SalesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

//盈亏表
@RestController
@RequestMapping("statement")
public class PALStatementController {
    @Autowired
    private ReportsService reportsService;
    @Autowired
    private PALStatementService palStatementService;

    /*
    *支出
    * 报废商品金额
    */
    @RequestMapping("queryOutlay")
    public Double queryOutlay(ReportsVo reportsVo){

        return this.palStatementService.queryOutlay(reportsVo);
    }
    /*
    * 收入
    * 销售金额-进货金额
    * */
    @RequestMapping("queryRevenue")
    public Double queryRevenue(ReportsVo reportsVo){

        return this.palStatementService.queryRevenue(reportsVo);
    }
    /*
     * 盈亏表统计
     * 收入
     * 支出
     * 利润（收入-支出）
     * */
    @RequestMapping("queryProfit")
    public Double queryProfit(ReportsVo reportsVo) {
        reportsVo.setOutlay(this.palStatementService.queryOutlay(reportsVo));
        reportsVo.setRevenue(this.palStatementService.queryRevenue(reportsVo));
        reportsVo.setProfit(reportsVo.getRevenue()-reportsVo.getOutlay());
        return reportsVo.getProfit();
    }

    /*
    return 数组
    *返回查询月份
    * 每月的支出
    * 每月收入
    * 每月利润
    * */
    @RequestMapping("monthlysum")
    public ReportsVo querymonthly(ReportsVo reportsVo){

          return this.palStatementService.queryMonthly(reportsVo);
    }
    /*
    * 查询正利润商品排行
    * */
    @RequestMapping("querypprofit")
    public List<Map.Entry<String, Double>> querypprofit(ReportsVo reportsVo){
        return this.palStatementService.querypprofit(reportsVo);
    }
    /*
    * 查询负利润商品排行
    * */
    @RequestMapping("querynprofit")
    public  List<Map.Entry<String, Double>> querynprofit(ReportsVo reportsVo)
    {
        return this.palStatementService.querynprofit(reportsVo);
    }

}
